package com.cskaoyan.controller.admin;

import com.cskaoyan.bean.BaseRespVo;
import com.cskaoyan.bean.admin.vo.GoodsStatisticsVo;
import com.cskaoyan.bean.admin.vo.OrderStatisticsVo;
import com.cskaoyan.bean.admin.vo.UserStatisticsVo;
import com.cskaoyan.service.GoodsService;
import com.cskaoyan.service.OrderGoodsService;
import com.cskaoyan.service.UserService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("admin/stat")
public class UserStatisticsController {
    @Autowired
    UserService userService;

    @Autowired
    OrderGoodsService orderGoodsService;

    @Autowired
    GoodsService goodsService;


//    @RequiresPermissions("admin:stat:user")
    @RequestMapping("user")
    public BaseRespVo statUser(){
        UserStatisticsVo userStatisticsVo = userService.selectUserStatistics();

        return BaseRespVo.ok(userStatisticsVo);
    }

//    @RequiresPermissions("admin:stat:order")
    @RequestMapping("order")
    public BaseRespVo statOrder(){
        OrderStatisticsVo orderStatisticsVo = userService.selecOrderStatistics();

        return BaseRespVo.ok(orderStatisticsVo);
    }

//    @RequiresPermissions("admin:stat:goods")
    @RequestMapping("goods")
    public BaseRespVo statGoods(){
        GoodsStatisticsVo goodsStatisticsVo = orderGoodsService.selectGoodsStatistics();

        return BaseRespVo.ok(goodsStatisticsVo);
    }
}
